package exsun.jt808.data.base;


import java.io.Serializable;

public class StatusResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 时间戳
     */
    private long timestamp = System.currentTimeMillis();

    /**
     * 返回代码
     */
    private int code;

    /**
     * 返回代码
     */
    private String msg;

    /**
     * 返回数据对象 data
     */
    private T result;

   /**
    *返回错误结果信息
   */
    private String message;
    public StatusResult(Enum status) {
        this.code = status.ordinal();
        this.msg = status.name();
    }
    public StatusResult(Enum status, T result) {
        this.code = status.ordinal();
        this.msg = status.name();
        this.result = result;
    }

    public StatusResult(Enum status, T result, String message) {
        this.code = status.ordinal();
        this.msg = status.name();
        this.result = result;
        this.message=message;
    }

    public boolean StatusEqual(Enum status) {
        if(this.code == status.ordinal()&&this.msg == status.name()){
            return true;
        }
        return false;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public long getTimestamp() {
        return timestamp;
    }



    public T getResult() {
        return result;
    }

    @Override
    public String toString() {
        return "{" +
                "message='" + getMsg() + '\'' +
                ", code=" + getCode() +
                ", timestamp=" + timestamp +
                '}';
    }
}
